package org.traffometer.traffobase.webapp.control.command;

import org.traffometer.traffobase.model.PacketStore;
import org.traffometer.traffobase.webapp.control.Page;
import javax.servlet.http.HttpServletRequest;

/**
 * Implements the "Display" command which simply displays the current state
 * of the stack.
 *
 * @author Philip Johnson
 */
public class DisplayCommand implements Command {

  /**
   * Processes the "Display" command sent by the user.
   * Sets the stackIterator attribute with the current stack contents.
   *
   * @param request The request object.
   * @param packetStore The packet store.
   * @return The page to be displayed (Page.INDEX).
   */
  public Page process(HttpServletRequest request, PacketStore packetStore) {
    request.setAttribute("packetStoreIterator", packetStore.iterator());
    return Page.INDEX;
  }
}